package com.surthi.app.magazine;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.surthi.app.magazine.dao.impl.DocumentAccessImpl;
import com.surthi.app.magazine.model.Document;
import com.surthi.app.magazine.util.DocumentUtils;

public class MagazineMain {
	private static final Logger LOGGER = LoggerFactory
			.getLogger(MagazineMain.class);
	private static final String FILE = "C:/Documents and Settings/Ravi Surthi/My Documents/Downloads/Clean_Code.pdf";

	public static void main(String[] args) {
		//DocumentAccess impl = new DocumentAccessImpl();
		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:ApplicationContext.xml");
		DocumentAccessImpl impl = context.getBean(DocumentAccessImpl.class);
		try{
			Document doc = Document.getInstance("2012","Jan","CleanCode.pdf",DocumentUtils.getStream(FILE));
			LOGGER.info("Document created : " + impl.createDocument(doc));
		}finally{
			context.close();
		}
	}
}
